import python_baway.exercise.mysql.oop.MysqlHelper as MysqlHelper
from python_baway.common.xdb import xdb_args
from python_baway.common.xcommon import sep

xhelper = MysqlHelper.MysqlHelper(**xdb_args)

xtable_name = 'student_ppt14_page29'

sep('Try Modify and Change')

xsql = f"ALTER TABLE {xtable_name} MODIFY age int(11) unsigned"
xr = xhelper.exec(xsql)
print(f'Affected rows: {xr}')

xsql = f"ALTER TABLE {xtable_name} CHANGE age the_age tinyint(3) unsigned"
xr = xhelper.exec(xsql)
print(f'Affected rows: {xr}')

xsql = f"ALTER TABLE {xtable_name} CHANGE the_age age tinyint(3) unsigned default 0"
xr = xhelper.exec(xsql)
print(f'Affected rows: {xr}')

sep('Try Add and Drop')

xsql = f"ALTER TABLE {xtable_name} ADD home varchar(512) NULL DEFAULT NULL"
xr = xhelper.exec(xsql)
print(f'Affected rows: {xr}')

xsql = f"ALTER TABLE {xtable_name} DROP home"
xr = xhelper.exec(xsql)
print(f'Affected rows: {xr}')

xhelper.close()